//MementoKeeper.java
package memento.blackbox;

import java.util.ArrayDeque;
import java.util.Deque;

/**
 * memento keeper has a narrow interface to access to Memento.
 * It makes MementoKeeper can't change the memento.
 *@author:youtubezou
 *@version:2012-8-16
 */
public class MementoKeeper
{
	private Deque<Memento> mementoes = new ArrayDeque<Memento>();
	
	
	public void pushMemento(Memento memento)
	{
		mementoes.push(memento);
	}
	
	public Memento popMemento()
	{
		if(mementoes.size() > 0) {
			return mementoes.pop();
		}
		return null;
	}
	
	public Memento peekMemento()
	{
		if(mementoes.size() > 0){
			return mementoes.peek();
		}
		return null;
	}
}
